package com.hxd.otc.module.wallet.activity;

import android.app.Activity;
import android.support.v7.widget.SimpleItemAnimator;

import com.hxd.otc.R;
import com.hxd.otc.base.BaseRecyclerActivity;
import com.hxd.otc.dialog.ConfirmDeleteDialog;
import com.hxd.otc.module.wallet.adapter.CurrencyConverterAdapter;
import com.hxd.otc.module.wallet.bean.WalletCoinRateVoBean;
import com.hxd.otc.module.wallet.contract.CurrencyConverterContract;
import com.hxd.otc.module.wallet.presenter.CurrencyConverterPresenter;


/**
 * Created by lzy on 2018/7/30 0030.
 * description ${汇率换算}
 */
public class CurrencyConverterActivity extends BaseRecyclerActivity<CurrencyConverterPresenter, CurrencyConverterAdapter, WalletCoinRateVoBean> implements CurrencyConverterContract.View {
    private ConfirmDeleteDialog mDialog;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_currency_converter;
    }

    @Override
    protected CurrencyConverterAdapter createAdapter() {
        return new CurrencyConverterAdapter(this);
    }

    @Override
    protected CurrencyConverterPresenter createPresenter() {
        return new CurrencyConverterPresenter(this);
    }

    @Override
    protected void initData() {
        super.initData();
        ((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
        mPresenter.onRefresh();
    }

    @Override
    public void onItemClick(int position) {
        switch (mAdapter.getItemViewType(position)) {
            case CurrencyConverterAdapter.ITEM_TYPE_NORMAL:
                mAdapter.selectedItem(position);
                break;
            case CurrencyConverterAdapter.ITEM_TYPE_BANNER:
            default:
                mDialog = new ConfirmDeleteDialog(this)
                        .setTitleText(R.string.do_you_jump_to_the_trading_interface)
                        .setOnConfirmClickListener(new ConfirmDeleteDialog.OnConfirmClickListener() {
                            @Override
                            public void onConfirm() {
                                skipOrderFragment();
                            }
                        });
                mDialog.show();
                break;
        }
    }

    private void skipOrderFragment() {
        setResult(Activity.RESULT_OK);
//        Bundle bundle = new Bundle();
//        bundle.putInt(MainActivity.EXTRA_SKIP_FROM_FLAG, MainActivity.EXTRA_SKIP_FROM_FLAG_CURENCY_CONVERTER);
//        $startActivity(MainActivity.class, bundle, true);
    }

    @Override
    public boolean isEnableRefresh() {
        return false;
    }

    @Override
    public boolean isAutoRefresh() {
        return false;
    }

    @Override
    public boolean isEnableLoadMore() {
        return false;
    }
}
